//
//  RequestManager.h
//  片刻
//
//  Created by admin on 15/6/4.
//  Copyright (c) 2015年 iApple. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, RequestModel) {
    POST,
    GET
};

@protocol RequestDelegate <NSObject>
//请求完毕后让代理对象执行的方法，同时把请求完的data传给代理对象
- (void)requestDidFinishWithData:(NSData *)data;
//请求失败后把错误原因传给代理对象
- (void)requestError:(NSError *)error;

@end

@interface RequestManager : NSObject<NSURLConnectionDataDelegate>
@property(nonatomic,retain)NSString *requestURL;
@property(nonatomic,retain)NSString *requestParameter;
@property(nonatomic,assign)RequestModel requestModel;
@property(nonatomic,retain)NSMutableData *data; //接受返回的data
@property(nonatomic,assign)id<RequestDelegate> delegate;
@property(nonatomic,retain)NSMutableDictionary *parameterDic;

- (instancetype) initWithRequestURL:(NSString *)urlString requestModel:(RequestModel )requestModel requestParameter:(NSString *)parameter;
- (void)startRequest;
@end
